package utils

import (
	"crypto/tls"
	"net/smtp"

	"github.com/jordan-wright/email"
)

// 发送邮件
func (Utils) EmailRetryErrorMsg(toEmail string, serviceName string, msg string, code string) error {
	e := email.NewEmail()
	e.From = "chf <1743309009@qq.com>"
	e.To = []string{toEmail}
	e.Subject = "go-weixin-retry-error服务异常"
	e.HTML = []byte("您的服务: <h1>" + serviceName + "</h1>\n" + "异常信息: <p>" + msg + "</p>\n" + "状态码: <p>" + code + "</p>")
	err := e.SendWithTLS("smtp.qq.com:465", smtp.PlainAuth("", "1743309009@qq.com", "gzxudkalfxofebda", "smtp.qq.com"),
		&tls.Config{InsecureSkipVerify: true, ServerName: "smtp.qq.com"})

	if err != nil {
		return err
	}
	return nil
}
